#include<iostream>
#include<string>
#include<string.h>
#include<vector>
#include<cstdio>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
using namespace std;
#define ll long long
#define pi acos(-1)


signed main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		int n,m;
		scanf("%d%d",&n,&m);
		string s;
		cin>>s;
		int i = 0;
		while(n--)
		{
			for(int j=1;j<=m;++j,++i)
			cout<<s[i];
			cout<<endl;
		}
	}
	return 0;
}
